<template>
  <div id="app">
    <kbl-header class="fixed-kbl-header"></kbl-header>
      <keep-alive>
          <router-view/>
      </keep-alive>
  </div>
</template>

<script>
import tabBar from './components/public/tab'
import kblHeader from './components/public/kblHeader'

export default {
  name: 'App',
  data(){
    return {
      transitionName:''
    }
  },
  components:{
    tabBar,
    kblHeader
  },
  mounted(){
    
  },
  watch:{
     $route(to, from) {
      //如果to索引大于from索引,判断为前进状态,反之
      if (to.meta.index > from.meta.index) {
        this.transitionName = 'slide-left';
      } else {
        this.transitionName = 'slide-right';
      }
    }
  }
}
</script>

<style lang='less'>
@rem:100rem;

#app {
  width: 750/@rem;
  margin: 0 auto;
  font-family: 'Microsoft Yahei', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #333;
  background: #f2f2f2;
  position: relative;
  font-size: 26/@rem;
}

.fixed-kbl-header{
    position: fixed;
    left: 0;
    top: 0;
    z-index: 999;
    width: 100%;
    background: #fff;
    transform: translateZ(0);
}

.slide-right-enter-active,
.slide-right-leave-active,
.slide-left-enter-active,
.slide-left-leave-active {
    will-change: transform;
    transition: all 500ms;
    position: absolute;
}
.slide-right-enter {
    opacity: 0;
    transform: translate3d(-100%, 0, 0);
}
.slide-right-leave-active {
    opacity: 0;
    transform: translate3d(100%, 0, 0);
}
.slide-left-enter {
    opacity: 0;
    transform: translate3d(100%, 0, 0);
}
.slide-left-leave-active {
    opacity: 0;
    transform: translate3d(-100%, 0, 0);
}
</style>
